<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>

  <link rel="stylesheet" type="text/css" href="./css/demo.css">
  <link rel="stylesheet" type="text/css" href="./css/zTreeStyle.css">
  <!-- <link rel="stylesheet" href="./css/zTreeStyle.css"> -->
</head>
<body>
  <button id="btn">click</button>
  <div id="accessTree" class="ztree"></div>
</body>
<script src="./js/jquery-1.8.3.min.js"></script>
<script src="./js/jquery.ztree.all.min.js"></script>
<script>

  // 初始化ztree
  var setting = {
			async:{
				enable: true,
				url:'data/b.json',
				type:'get',
			},
			check:{
				enable:true,
			},
		};
  $.fn.zTree.init($("#accessTree"), setting);

  // 绑定点击事件
  $('#btn').click(function(){
    var ztreeObj = $.fn.zTree.getZTreeObj('accessTree');
    var checkZnodes = ztreeObj.getCheckedNodes();
    var checkedValueArr = [];
    $.each(checkZnodes, function(czi,czv){
      checkedValueArr.push(czv.id);
    })
    console.log(checkedValueArr);
    $.ajax({
      url:'',
      method:'get',
      data: {

      },
      dataType:'json',
      success: function(){

      },
      error: function(){

      }
    })
  })
</script>
</html>
